﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MuXue.Zyiz.Template.Domain.Model
{
    public class Result<T>
    {
        public bool state { get; set; }
        public String error_code { get; set; }
        public String error_msg { get; set; }
        public T data { get; set; }
    }
    public static class ErrorCode
    {
        /// <summary>
        /// 没有登录
        /// </summary>
        public const string LoginError = "1001";

        /// <summary>
        /// 系统错误
        /// </summary>
        public const string SystemError = "1002";

        /// <summary>
        /// Json参数格式错误
        /// </summary>
        public const string JsonError = "1003";

        /// <summary>
        /// 用户名或密码错误
        /// </summary>
        public const string AuthorizeError = "1004";

        /// <summary>
        /// 手机号格式错误
        /// </summary>
        public const string PhoneFormatError = "1005";
        // <summary>
        /// 参数错误
        /// </summary>
        public const string ParamError = "1006";


        /// <summary>
        /// 执行sql报错
        /// </summary>
        public const string SqlExcuteError = "5000";

        /// <summary>
        /// 系统级别错误，比如try catch里抛出异常
        /// </summary>
        public const string SysExceptionError = "4000";

        /// <summary>
        /// 系统错误，请再重试
        /// </summary>
        public const string NeedTryAgin = "4004";

        /// <summary>
        /// 调用外部接口报错
        /// </summary>
        public const string OuterApiError = "4005";

        /// <summary>
        /// 根据返回码获取返回消息
        /// </summary>
        /// <param name="returnCode">返回码</param>
        /// <returns>返回消息</returns>
        public static string GetErrorMsg(string error_code)
        {
            switch (error_code)
            {
                case ErrorCode.LoginError: return "未登录";
                case ErrorCode.SystemError: return "系统错误";
                case ErrorCode.JsonError: return "Json参数格式错误";
                case ErrorCode.AuthorizeError: return "用户名或密码错误";
                case ErrorCode.PhoneFormatError: return "手机号格式错误";
                case ErrorCode.SqlExcuteError: return "执行sql报错";
                case ErrorCode.ParamError: return "参数错误";
                case ErrorCode.SysExceptionError: return "系统执行异常";
                case ErrorCode.NeedTryAgin: return "系统错误，请再重试";
                case ErrorCode.OuterApiError: return "调用外部接口报错，请再重试";
                default: return null;
            }
        }


    }

}
